<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<script type="text/javascript" src="echarts.min.js"></script>
<script type="text/javascript" src="jquery-1.8.3.min.js"></script>

<body>
	<h2>下列框请输入微博用户网址url 例如：https://m.weibo.cn/profile/info?uid=2194868354</h2>
	<h2 id="h"></h2>
	<input type="text" id="u"/>
	<br/>
	<input type="button" onclick="test()" value="获取评论分词"/>
	<input type="button" onclick="test2()" value="获取情感分析倾向"/>
	<br/>
	<div  style="width: 400px;height:500px;float:left;"><img id="t" style="width: 1500px;height: 850px;" src="\\app\\123.png"/></div>
	<div  id="main" style="width: 600px;height:400px;float:left;"></div>
	<!--  
	<a href="http://127.0.0.1:6666/req/weibo?weiboUrl=https://m.weibo.cn/api/comments/show?id=4362895472547300&page=2">测试</a>
	-->
</body>
<script type="text/javascript">
var t1 = 200;
var t2 = 100;
var t3 = 120;
chart();
function test(){
	var weiboUrl = $("#u").val();
	$("#h").html("正在抓取用户评论，正在分词........");
	$.ajax({
		url : "http://127.0.0.1:6666/req/weibo",
		data : {
			weiboUrl : weiboUrl
		},
		dataType : "json",
		type : "post",
		success: function(data){
			alert(data.imgurl);
			$("#h").html("分词成功！");
			$("#t").attr("src",data.imgurl);
		},
		error : function(){
			alert("error!");
		}
	});
}
function test2(){
	$("#h").html("正在抓取用户评论，正在语句情感分析........");
	var weiboUrl = $("#u").val();
	$.ajax({
		url : "http://127.0.0.1:6666/req/weiboQG",
		data : {
			weiboUrl : weiboUrl
		},
		dataType : "json",
		type : "post",
		success: function(data){
			$("#h").html("情感倾向分析成功！");
			t1 = data.zheng;
			t2 = data.fu;
			t3 = data.zhong;
			chart();
		},
		error : function(){
			alert("error!");
		}
	});
}

function chart(){
	var myChart = echarts.init(document.getElementById('main'));

	var option = {
	   
	    tooltip : {
	        trigger: 'item',
	        formatter: "{a} <br/>{b} : {c} ({d}%)"
	    },
	    legend: {
	        // orient: 'vertical',
	        // top: 'middle',
	        bottom: 10,
	        left: 'center',
	       
	    },
	    series : [
	        {
	            type: 'pie',
	            radius : '65%',
	            center: ['50%', '50%'],
	            selectedMode: 'single',
	            data:[
	                 
	                {value:t1, name: '积极'+t1},
	                {value:t2, name: '消极'+t2},
	                {value:t3, name: '中性'+t3}
	            ],
	            itemStyle: {
	                emphasis: {
	                    shadowBlur: 10,
	                    shadowOffsetX: 0,
	                    shadowColor: 'rgba(0, 0, 0, 0.5)'
	                }
	            }
	        }
	    ]
	};
	myChart.setOption(option);
}


</script>
</html>